package com.kmust.dream.wanderingdream.product.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class MyMetaObject implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        //设置属性值---三个参数fieldName、fieldVal、metaObject
        this.setFieldValByName("create_time",new Date(),metaObject);
    }
    @Override
    public void updateFill(MetaObject metaObject) {
        //修改时只需修改更新时间
        this.setFieldValByName("update_time",new Date(),metaObject);
    }
}

